import { createRouter, createWebHistory } from "vue-router";
import FilmView from "../views/FilmView.vue";
import CinemaView from "../views/CinemaView.vue";
import NewsView from "../views/NewsView.vue";
import MineView from "../views/MineView.vue";
import AxiosDemo from "../demos/AxiosDemo.vue";

import NowPlaying from "../components/film/NowPlaying.vue";
import ComingSoon from "../components/film/ComingSoon.vue";
import Detail from "../views/Detail.vue";
import NotFound from "../views/NotFound.vue";
import Cities from "../views/Cities.vue";

const router = createRouter({
   history: createWebHistory(import.meta.env.BASE_URL),
   routes: [
      {
         path: "/",
         redirect: "/film",
      },

      {
         path: "/film",
         redirect: "/film/nowPlaying",
      },

      {
         path: "/film",
         name: "film",
         meta: { title: "电影", isTabPage: true },
         component: FilmView,

         children: [
            {
               path: "nowPlaying",
               component: NowPlaying,
            },
            {
               path: "comingSoon",
               component: ComingSoon,
            },
         ],
      },

      {
         path: "/cinema",
         name: "cinema",
         meta: { title: "影院", isTabPage: true },
         component: CinemaView,
      },

      {
         path: "/news",
         name: "news",
         meta: { title: "资讯", isTabPage: true },
         component: NewsView,
      },

      {
         path: "/mine",
         name: "mine",
         meta: { title: "个人中心", hideTitle: true },
         component: MineView,
      },

      {
         path: "/demos/axios",
         name: "axios",
         component: AxiosDemo,
      },

      {
         path: "/film/:id(\\d{4})",
         name: "detail",
         meta: { hideTabBar: true },
         component: Detail,
      },

      {
         path: "/cities",
         name: "cities",
         meta: { title: "当前城市-", hideTabBar: true },
         component: Cities,
      },

      {
         path: "/:pm(.*)*",
         name: "notfound",
         component: NotFound,
      },
   ],
});

export default router;
